﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;

namespace WindowsFormsApplication1.FindFriends
{
    public class FindFriendsResult
    {
        public FindFriendsResult(ServerSocketData respondingServer)
        {
            server = respondingServer;
        }

        public ServerSocketData server;
        public bool hasResponded = false;
        public List<FriendData> friendsLocated = new List<FriendData>();
    }

    //Helper class used to store the friend information returned by world servers
    public class FriendData
    {
        public int ID = -1;
        public string Name = "";
        public int mapid = -1;
        public int instance = -1;

        public string toXML()
        {
            string result = "";

            StringWriter stringWriter = new StringWriter();
            XmlTextWriter xmldoc = new XmlTextWriter(stringWriter);

            xmldoc.WriteStartElement("frienddata");

            xmldoc.WriteAttributeString("id", ID.ToString());
            xmldoc.WriteAttributeString("name", Name);
            xmldoc.WriteAttributeString("mapid", mapid.ToString());
            xmldoc.WriteAttributeString("instance", instance.ToString());

            xmldoc.WriteEndElement();
            xmldoc.Flush();

            xmldoc.Close();

            stringWriter.Flush();

            result = stringWriter.ToString();

            return result;
        }
    }
}
